#pragma once
#include <iostream>

// the abs class
struct Handler {
  Handler() {
    successor = NULL;        
  }

  virtual void HandleRequest()=0 ;// interface
  void SetSuccessor(Handler* suc) {
    successor = suc;
  }
  protected:
  Handler* successor; // the son class pointer
};

// impl abs class Handler
struct MoreClearHandler : public Handler {
  void HandleRequest() override {
    if (successor != NULL) {
      std::cout << "[DBEUG]: Enter [MoreClearHandler::HandleRequest()]" << std::endl;
      successor->HandleRequest(); // son class run his request
    } else {
      std::cout << "No son class anymore" << std::endl;
    }
  }
};

struct MoreClearHandler2 : public Handler {
  void HandleRequest() override {
    if (successor != nullptr) {
      std::cout << "[DEBUG]: Enter [MoreClearHandler2::HandleRequest()]"<< std::endl;
      successor->HandleRequest();
    } else {
      std::cout << "No son class anymore" << std::endl;
    }
  }
};
